<template >
  <div class="pa-dialog">
    <!-- <el-button icon="el-icon-search" @click="filterHandle()" circle :type="Objqual()?'':'primary'"></el-button>
    <el-dialog :visible.sync="visible" :title="'过滤用户'" :close-on-click-modal="false" :close-on-press-escape="false"
      :width="'70%'">
      <el-form v-loading="loading" :model="dataForm" ref="dataForm" :label-width="$i18n.locale === 'en-US' ? '120px' : '90px'"
        :inline="true">
        <el-form-item prop="username" :label="$t('user.username')">
          <el-input v-model="dataForm.likeName" :placeholder="$t('user.username')" :disabled="dataForm.id ? true : false">
          </el-input>
        </el-form-item>
        <el-form-item prop="deptId" :label="$t('user.deptName')" class="dept-list">
          <uni-tree-select v-model="dataForm.deptId" ref="treeSelectDept" :data="deptList" />
        </el-form-item>
        <el-form-item prop="mobile" :label="$t('user.mobile')">
          <el-input v-model="dataForm.mobileLike" :placeholder="$t('user.mobile')"></el-input>
        </el-form-item>
      </el-form>
      <template slot="footer">
        <el-button @click="visible = false">{{ $t('cancel') }}</el-button>
        <el-button @click="filterClean">{{ '清空' }}</el-button>
        <el-button type="primary" :loading="loading" @click="dataFormSubmitHandle()">{{ $t('confirm') }}</el-button>
      </template>
    </el-dialog> -->
    <el-form v-loading="loading" :model="dataForm" ref="dataForm" :inline="true">
      <el-form-item prop="username" :label="$t('user.username')">
        <el-input v-model="dataForm.likeName" :placeholder="$t('user.username')" clearable>
        </el-input>
      </el-form-item>
      <!-- <el-form-item prop="deptId" :label="$t('user.deptName')" class="dept-list">
        <uni-tree-select v-model="dataForm.deptId" ref="treeSelectDept" :data="deptList" />
      </el-form-item>
      <el-form-item prop="mobile" :label="$t('user.mobile')">
        <el-input v-model="dataForm.mobileLike" :placeholder="$t('user.mobile')"></el-input>
      </el-form-item> -->
      <el-form-item>
        <el-button icon="el-icon-refresh" @click="dataFormSubmitHandle()" circle></el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<style lang="scss">
// .pa-dialog .el-dialog__body {
//   padding: 10px 10px;
//   padding-right: 30px;
// }
// .pa-dialog .left {
//   text-align: right;
//   vertical-align: middle;
//   float: left;
//   font-size: 14px;
//   line-height: 32px;
//   padding: 0 12px 0 0;
//   box-sizing: border-box;
// }
// .pa-dialog .el-row + .el-row {
//   margin-top: 10px;
// }
</style>

<script>
import debounce from 'lodash/debounce'
// import { treeDataTranslate } from '@/utils/index'

let _dataForm = {
  likeName: '',
  deptId: '',
  mobileLike: ''
}

export default {
  data () {
    return {
      visible: false,
      loading: false,
      deptList: [],
      dataForm: { ..._dataForm }
    }
  },
  computed: {},
  props: {
    backFun: {
      type: Function,
      required: false
    },
    deptListProp: {
      type: Array,
      required: false
    }
  },
  watch: {
    deptListProp: function (newVal) {
      this.deptList = newVal
    }
  },
  created () {
    this.init()
  },
  methods: {
    init () {
      // if (!this.deptListProp) {
      // this.getDeptList()
      // }
    },
    // Objqual () {
    //   return this.isObjectValueEqual(_dataForm, this.dataForm)
    // },
    // /**
    //  * b 与 a中有的属性，值是否一致
    //  */
    // isObjectValueEqual (a, b) {
    //   var aProps = Object.getOwnPropertyNames(a)
    //   // var bProps = Object.getOwnPropertyNames(b)
    //   // if (aProps.length !== bProps.length) {
    //   //   return false
    //   // }
    //   for (var i = 0; i < aProps.length; i++) {
    //     var propName = aProps[i]
    //     if (a[propName] !== b[propName]) {
    //       return false
    //     }
    //   }
    //   return true
    // },
    // filterClean () {
    //   this.clean()
    //   this.filterSubmitHandle()
    // },
    // clean () {
    //   this.dataForm = { ..._dataForm }
    // },
    // 查询窗口处理
    filterSubmitHandle () {
      this.backFun({ ...this.dataForm })
      this.visible = false
    },
    getData () {
      return this.dataForm
    },
    // filterHandle () {
    //   this.visible = true
    // },
    // 获取部门列表
    // getDeptList () {
    //   return this.$http.get('/sys/dept/list').then(({ data: res }) => {
    //     if (res.code !== 0) {
    //       return
    //     }
    //     this.deptList = treeDataTranslate(res.data)
    //   }).catch(() => { })
    // },
    // 表单提交
    dataFormSubmitHandle: debounce(function () {
      this.filterSubmitHandle()
    }, 1000, { 'leading': true, 'trailing': false })
  }
}
</script>

<style lang="scss">
</style>
